#include "vmlinux.h"
#include <bpf/bpf_endian.h>
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>

#define TC_ACT_OK 0

struct {
    __uint(type, BPF_MAP_TYPE_ARRAY);
    __uint(max_entries, 1);
    __type(key, int);
    __type(value, u64);
} count SEC(".maps");

SEC("tc")
int tc_ingress(struct __sk_buff *ctx)
{
    int zero = 0;
    u64 *value;

    value = bpf_map_lookup_elem(&count, &zero);
    if (value) {
        __sync_fetch_and_add(value, 1);
    }

    return TC_ACT_OK;
}

char _license[] SEC("license") = "GPL";